package deploy;

import common.BlockInfo;
import common.FileInfo;
import server.ClientImpl;

import java.rmi.RemoteException;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

public class downLoad {
    public static void main(String[] args) throws RemoteException {

        test3();
//        Date before = new Date();
//        test2();
//        Date after = new Date();
//        System.out.println(after.getTime()-before.getTime());

    }

    private static void test3() throws RemoteException {
        ClientImpl client = new ClientImpl("localhost",1099);
        List<FileInfo> list = client.list();
        for (FileInfo fileInfo : list) {
            System.out.println(fileInfo.getFileName());
            System.out.println(fileInfo.getBlockList());
            System.out.println(fileInfo.getStatus());
        }
    }

    public static void test1(){

        ClientImpl client = new ClientImpl("localhost",1099);
//        ClientImpl client = new ClientImpl("localhost",30000);
        try {
            System.out.println("上传文件测试");
            List<BlockInfo> out = client.put("","hadoop-3.1.4.tar.gz" , "hadoop-3.1.4.tar.gz");
        } catch (RemoteException e) {
            e.printStackTrace();
        }

    }


    public static void test2(){
        ClientImpl client = new ClientImpl("localhost",1099);
//        ClientImpl client = new ClientImpl("localhost",30000);
        try {
            System.out.println("下载文件测试");
            boolean flag = client.getFile("", "hadoop-3.1.4.tar.gz", "hh//");
            System.out.println(flag);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
}
